<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>进货单管理</title>
<jsp:include page="/common.jsp" />
<script type="text/javascript">
var options={
		create:{
			url:'${pageContext.request.contextPath}/system/stock/toAdd.htm',
			title:'新增进货单',
			width:480,
			height:380
		},

		view:{
			url:'${pageContext.request.contextPath}/system/stock/toView.htm',
			title:'进货单详细',
			width:480,
			height:400
		},

		modify:{
			url:'',
			title:''
		},
			
		remove:{
			url:''
		}
	};
</script>
</head>

<body>
	<table cellpadding="0" cellspacing="0" width="100%" height="100%">
		<tbody>
			<tr>
				<td>
					<div class="toolbar" style="background-color: #e0e0e0;">
					   <a plain="true" href="javascript:void(0);"
							class="easyui-linkbutton" iconCls="icon-add" onclick="toDo(options,'C');">新增</a>
						<a plain="true" href="javascript:void(0);"
							class="easyui-linkbutton" iconCls="icon-search" onclick="toDo(options,'V');">查看</a>
						<!-- <a plain="true" href="javascript:void(0);"
							class="easyui-linkbutton" iconCls="icon-save" onclick="toDo(options,'M');">编辑</a>
						<a plain="true" href="javascript:void(0);"
							class="easyui-linkbutton" iconCls="icon-remove" onclick="toDo(options,'R');">删除</a>
						<a plain="true" href="javascript:void(0);" 
							class="easyui-linkbutton" iconCls="icon-save" onclick="assign();">分配</a> -->
							<c:if test="${formBean.isAll }">
							分组: 
							<select id="chngroup"> 
								 <option value="userId">用户编号</option>
								 <option value="productId">服装编号</option> 
								 <option value="supplierId">供应商编号</option>
								 <option value="stockStatus">采购状态</option> 
								 <option value="clear">移除分组</option> 
							</select>
							</c:if>
					</div>
				</td>
			</tr>
			
			<tr>
				<td height="100%" valign="top" width="100%">
					<table id="lister" name="lister" style="width:100%;height:100%"></table>
					<div id="pager"></div>
				</td>
			</tr>
		</tbody>
	</table>
	<div id='win' class='easyui-window' title='New Window' style='width:400px;height:300px;padding:5px;' closed='true'>
	</div>
	<script>
	 $(document).ready(function(){
    	 $("#lister")
			.jqGrid(
					{
						url : "${pageContext.request.contextPath }/system/stock/listBy.htm?isAll=${formBean.isAll }",
						datatype : "json",
						colNames : [ '采购编号','用户编号','采购日期','供应商编号','服装编号','采购数量','采购颜色','采购尺寸','采购价格','折扣','采购总价','采购状态'],
						colModel : [ 
									{name : 'id',index : 'stock_no',summaryType:'count', summaryTpl:'<b>{0} 项</b>'}, 
									{name : 'userId',index : 'user_id'},
									{name : 'stockDate',index : 'stock_date',searchtype:"number"},
									{name : 'supplierId',index : 'supplier_id'},
									{name : 'productId',index : 'product_id',searchtype:"number"},
									{name : 'productCount',index : 'product_count',searchtype:"number",summaryType:'sum',summaryTpl:'<b>总计:{0}</b>'},
									{name : 'productColor',index : 'product_color'},
									{name : 'productSize',index : 'product_size'},
									{name : 'productPrice',index : 'product_price',searchtype:"number"},
									{name : 'discount',index : 'discount',searchtype:"number",summaryType:'min', summaryTpl:'<b>最小: {0}</b>'},
									{name : 'total',index : 'total',searchtype:"number",summaryType:'sum',summaryTpl:'<b>总计:{0}</b>'},
									{name : 'stockStatus',index : 'stock_status',searchtype:"number"}
									],
						rowNum : 10,
						shrinkToFit: true,
						rowList : [ 10, 20, 30 ],
						pager : '#pager',
						sortname : 'stock_date',
						viewrecords : true,
						sortorder : "desc",
						mtype: "POST",
						multiselect: true,
						height:'auto',
						width:'100%',
						grouping:<c:out value="${formBean.isAll}"></c:out>, 
						groupingView : { 
							groupField : ['productId'], 
							groupSummary : [true],
							groupColumnShow : [true], 
							groupText : ['<b>{0}</b>'], 
							groupCollapse : false, 
							groupOrder: ['asc'] 
						}
					});
		$("#lister").jqGrid('navGrid','#pager', {edit : false,add : false,del : false});
      });
	 
	 $("#chngroup").change(function() {
			var vl = $(this).val();
			if (vl) {
				if (vl == "clear") {
					$("#lister").jqGrid('groupingRemove', true);
				} else {
					$("#lister").jqGrid('groupingGroupBy', vl);
				}
			}
		});
	</script>
</body>
</html>